(ns zesql.bench
  (:require [zesql.core :as zs :refer [defqueries]]
            [hikari-cp.core :refer [make-datasource]]))


(set! *warn-on-reflection* true)

(zs/debug-on!)
(zs/cache-on!)

(def db-spec
  {:datasource (make-datasource {:adapter "h2"
                                 :url     "jdbc:h2:./zesql"})
   :naming     {:keys   clojure.string/lower-case
                :fields clojure.string/upper-case}})


(declare test-where)
(defqueries "zesql/query.sql" {:connection db-spec})
(println "-------------")

(println (test-where {:id 2 :name "bbb"}))
;(dotimes [_ 20]
;  (time
;    (dotimes [_ 1000]
;      (test-where {:id 2 :name "bbb"}))))

(dotimes [_ 20]
  (test-where {:id 2 :name "bbb"})
  (println "---"))
